package Demo01;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Test {
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(1);
        list.add(1);
        list.add(1);

        Iterator<Integer> iterator = list.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next()+" ");
        }

/*        for (Integer x : list) {
            System.out.print(x+" ");
        }*/
/*        for (int i = 0; i < list.size(); i++) {
            System.out.print(list.get(i)+" ");
        }*/

    }
    public static void main02(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);
        list.remove(new Integer(4));
        System.out.println(list);
    }
    public static void main01(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(1);
        list.add(1);

        ArrayList<Number> list1 = new ArrayList<>();
        list1.addAll(list);

        list1.remove(0);
        System.out.println(list1);
    }

}

class Solution {
    public List<List<Integer>> generate(int numRows) {
        List<List<Integer>> ret = new ArrayList<>();
        List<Integer> fir = new ArrayList<>();
        fir.add(1);
        ret.add(fir);
        for(int i = 1;i<numRows;i++) {
            List<Integer> curList = new ArrayList<>();
            curList.add(1);
            List<Integer> prevList = ret.get(i-1);
            for(int j = 1;j<i;j++) {
                curList.add(prevList.get(j-1)+prevList.get(j));
            }
            curList.add(1);
            ret.add(curList);
        }
        return ret;
    }
}